<template>
  <div>
  <DataList
    :cate="cate"
    :cols="cols"
    :name="name"
    :single="true"
  />
  </div>
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addDnzybdqk, deleteDnzybdqk, updateDnzybdqk, getDnzybdqk } from "@/api/当年专业变动情况.js";
import { get开设专业 } from "@/api/开设专业.js";
import { getZs } from "@/api/招生.js";
import linq from "linq";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A11-1当年专业变动情况",
      name:'11.1 当年专业变动情况',
      cols: [
        { label: "专业设置数(不含方向)", prop: "ZYSZS" },
        { label: "招生专业数(不含方向)", prop: "ZSZYS" },
        { label: "新增专业数(不含方向)", prop: "XZZYS" },
        { label: "停招专业数(不含方向)", prop: "TZZYS" },
        { label: "撤销专业数(不含方向)", prop: "CXZYS" }
      ]
    };
  },
  methods: {
    async onChange(model, field, value) {
      //
      // var user = getUser();
      // var kai = await get开设专业(user.XXID,user.CJPC);
      // var she=linq.from(kai).distinct("$.ZYDM").count()
      // model.ZYSZS = she;

      // var zs = await getZs(user.XXID,user.CJPC);
      // var zss=linq.from(zs).distinct("$.ZYMC").count()
      // model.ZSZYS = (zss-1);
    },
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addDnzybdqk(temp);
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateDnzybdqk(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteDnzybdqk(temp);
          resolve();
      })
    },
    async fetchData() {
      var user = getUser();
      var datas = await getDnzybdqk(user.XXID,user.CJPC);
      return datas;
    },
  }
};
</script>
<style>
</style>